package controllers

import (
	"github.com/astaxie/beego"
	"home/models"
)

type MainController struct {
	beego.Controller
}

func (this *MainController) Get() {
	this.TplName = "index.tpl"
	// 获取菜单数据
	var datalist []models.HomeMenu
	datalist, err := models.GetMenu()
	if err != nil {
		beego.Error(err)
	}
	this.Data["Menu"] = datalist

	// 获取趋势数据
	var dataList []models.HomeTrending
	dataList,err = models.GetTrendingList()
	if err != nil {
		//beego.Error(err)
	}
	this.Data["TrendingList"] = dataList

	// 获取热门影片
	var popularWithData []models.PopularWith
	popularWithData, err = models.GetPopularWith()
	if err != nil {
		beego.Error(err)
	}
	this.Data["PopularWithData"] = popularWithData

	// 获取最新影片
	var newVideoData []models.NewVideo
	newVideoData, err = models.GetNewVideo()
	if err != nil {
		beego.Error(err)
	}
	this.Data["NewVideoData"] = newVideoData

	// 获取最高分影片
	var maxVideoData []models.MaxScore
	maxVideoData, err = models.GetMaxScore()
	if err != nil {
		beego.Error(err)
	}
	this.Data["MaxVideoData"] = maxVideoData

	// 获取最受关注影片
	var mostConcerned []models.Mostconcerned
	mostConcerned, err = models.GetMostConcerned()
	if err != nil {
		beego.Error(err)
	}
	this.Data["MostConcerned"] = mostConcerned

	// 获取推荐影片
	var recommendData []models.Recommend
	recommendData, err = models.GetRecommendVideo()
	if err != nil {
		beego.Error(err)
	}
	this.Data["RecommendData"] = recommendData
}
